<template>
  <!-- book页头部 数据展示 -->
  <div class="Service_Book_container">
    <div class="container_image">
      <div class="image_item" v-for="(item, index) in length" :key="index">
        <img :src="image" alt="" />
      </div>
    </div>
    <div class="container_text">
      <div class="container_text_t">
        <p class="container_text_t_p">{{ title }}</p>
      </div>
      <div class="container_text_b">
        <div
          class="container_text_b_item"
          v-for="(item, index) in dataFn.container_text[0].paragraphs"
          :key="index"
        >
          <span>{{ item }}</span>
        </div>
      </div>
    </div>
    <div class="container_expand">
      <van-collapse v-model="activeNames">
        <van-collapse-item
          @click="Book_Ratings_BackTopChongwuTab()"
          disabled
          class="item_border_bottom"
          name="1"
        >
          <template #title>
            <div>
              {{ dataFn.container_score.text }}
              <!-- 评分 -->
              <div class="score">⭐{{ dataFn.container_score.score }}</div>
            </div>
          </template>
          <template #value>
            <div>See all({{ dataFn.container_score.total }})</div>
          </template>
        </van-collapse-item>
        <van-collapse-item
          disabled
          :title="dataFn.container_score.title"
          name="3"
        >
        </van-collapse-item>
      </van-collapse>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";
// 折叠数据
const activeNames = ref(["1"]);
const router = useRouter();
const route = useRoute();
// 定义响应式变量
const petId = ref(""); // 宠物 ID
const title = ref(""); // 标题
const src = ref(""); // 图片地址
// 头部数据
const dataFn = ref({
  // 头部下的文字
  container_text: [
    {
      title: "Pet Physical Examination",
      paragraphs: [
        "Return at any time",
        "Expire and return",
        "Need appointment",
      ],
    },
  ],
  // 头部下的评分
  container_score: {
    score: 4.9,
    text: "Ratings",
    total: 198,
    title: "Service details",
  },
});
// 跳转到评价页面
const Book_Ratings_BackTopChongwuTab = () => {
  router.push({
    name: "petDetail", // 必须与路由配置完全一致
   
  });
};

defineProps({
  image: {
    type: String,
    default: "",
  },
  length: {
    type: Number,
    default: 0,
  },
});
</script>

<style lang="less" scoped>
.Service_Book_container {
  padding-left: 15px;
  background-color: #fff;
  .container_image {
    height: 100px;
    overflow-x: scroll;
    display: flex;
    justify-content: space-between;
    align-items: center;
    &::-webkit-scrollbar {
      display: none;
    }
    .image_item {
      width: 100px;
      height: 100px;
      border-radius: 10px;
      flex-shrink: 0;
      margin-right: 10px;
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
  }
  .container_text {
    margin-top: 6px;

    .container_text_t {
      font-size: 16px;
      font-weight: bold;
      text-align: left;
    }
    .container_text_b {
      display: flex;
      align-items: center;
      margin-top: 6px;
      .container_text_b_item {
        padding: 4px 6px;
        box-sizing: border-box;
        margin-right: 10px;
        font-size: 11px;
        color: #b9bfc3;
        background-color: #f0f5f8;
        border-radius: 20px;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    }
  }
  ::v-deep(.container_expand) {
    margin-top: 15px;
    .van-collapse {
      .van-collapse-item {
        .van-collapse-item__content {
          display: none;
        }
        .van-cell {
          padding-left: 0;
          .van-cell__title {
            font-size: 16px;
            font-weight: bold;
            position: relative;
            .score {
              padding: 2px 6px;
              box-sizing: border-box;
              color: #fdb601;
              font-size: 11px;
              border-radius: 20px;
              border: 1px solid #fdb601;
              height: 20px;
              position: absolute;
              left: 65px;
              top: 50%;
              transform: translateY(-50%);
              display: flex;
              justify-content: center;
              align-items: center;
              white-space: nowrap;
            }
          }
          .van-badge__wrapper {
            display: none;
          }
          .van-cell__value {
            color: #55585a;
            position: relative;
            text-align: center;
            margin-left: 120px;
            &::before {
              content: "";
              position: absolute;
              width: 6px;
              height: 6px;
              border: 2px solid #7d7f82;
              border-left: 0;
              border-bottom: 0;
              transform: translate(-50%, -50%) rotate(45deg);
              top: 51%;
              right: 0;
            }
          }
        }
        .van-collapse-item__title--disabled {
          color: #000;
        }
        &::after {
          border: none;
        }
        &.item_border_bottom {
          border-bottom: 1px solid #ebedf0;
        }
      }
      &::after {
        border: none;
      }
    }
  }
}
</style>